00001
00010 #ifndef hal_cc2530znp_target_board_H
00011 #define hal_cc2530znp_target_board_H
00012
00013 #define HAL_SLEEP() ( __bis_SR_register(LPM3_bits + GIE))
00014 #define HAL_WAKEUP() ( __bic_SR_register_on_exit(LPM3_bits))
00015
00016
00017
00018
00019 #include "msp430x22x4.h"
00020 #include "../Common/printf.h"
00021 #include "../Common/utilities.h"
00022
00023
00024
00025
00026 void halInit();
00027 void halEnableInterrupts();
00028 void delayMs(unsigned int ms);
00029 void delayUs(unsigned int us);
00030 signed int toggleLed(unsigned char led);
00031 signed int setLed(unsigned char led);
00032 void clearLeds();
00033 void halSpiInitZnp();
00034 void spiWrite(unsigned char *bytes, unsigned char numBytes);
00035 unsigned int calibrateVlo();
00036 signed int initTimer(unsigned char seconds, unsigned char wakeOnTimer);
00037
00038
00039
00040
00041 unsigned int getVcc3();
00042 unsigned int getLightSensor();
00043
00044 void setZnpInterfaceToInputs(void);
00045
00046 void halSpiInitAccelerometer();
00047 signed int halEnableAccelerometerInterrupt(unsigned char wakeOnAccelerometer);
00048 unsigned char spiWriteAccelerometer(unsigned char b);
00049
00050
00051
00052
00053 #define RADIO_ON() (P3OUT |= BIT7) //ZNP Reset Line
00054 #define RADIO_OFF() (P3OUT &= ~BIT7)
00055
00056 #define SPI_SS_SET() (P3OUT &= ~(BIT0 | BIT6)) //active low, control SS and MRDY
00057 #define SPI_SS_CLEAR() (P3OUT |= (BIT0 | BIT6))
00058 #define SRDY_IS_HIGH() (P2IN & BIT6)
00059 #define SRDY_IS_LOW() ((~P2IN) & BIT6)
00060
00061 #define DEBUG_ON() (P4OUT |= BIT4)
00062 #define DEBUG_OFF() (P4OUT &= BIT4)
00063
00064 #define NO_WAKEUP 0
00065 #define WAKEUP_AFTER_TIMER 1
00066 #define WAKEUP_AFTER_ACCELEROMETER 2
00067
00068
00069
00070
00071 #define XTAL 8000000L
00072 #define TICKS_PER_MS (XTAL / 1000 / 5 - 1)
00073 #define TICKS_PER_US (TICKS_PER_MS / 1000)
00074
00075
00076 #define LIGHT_SENSOR_ON() (P2OUT |= BIT1) //ZNP Reset Line
00077 #define LIGHT_SENSOR_OFF() (P2OUT &= ~BIT1)
00078
00079
00080 #define ACCELEROMETER_SS_SET() (P2OUT &= ~(BIT2|BIT7)) //active low
00081 #define ACCELEROMETER_SS_CLEAR() (P2OUT |= (BIT2|BIT7))
00082 #define ACCELEROMETER_RX_BUF UCB0RXBUF
00083
00084
00085
00086
00087 #endif